package com.atguigu.uitl;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

/**
 * @author hjy
 * @create 2023/3/15 11:04
 */
public class KeyWordUtil {
    public static List<String> getIkWord(String keyword) throws IOException {
        ArrayList<String> wordList = new ArrayList<>();
        IKSegmenter ikSegmenter = new IKSegmenter(new StringReader(keyword), false);
        Lexeme next = ikSegmenter.next();
        while (next!=null){
            wordList.add(next.getLexemeText());
            next=ikSegmenter.next();
        }
        return wordList;
    }

}
